#include "stdafx.h"
#include "Engine.h"
#include "Sprite.h"

Graphics::Engine* Graphics::Engine::ourInstance = 0;

bool Graphics::Engine::Create(HINSTANCE aHInstance, const SetupInfo& aSetupInfo)
{
	ourInstance = new Engine;
	ourInstance->mySetupInfo = aSetupInfo;
	ourInstance->myDevice.InitDevice(aHInstance, aSetupInfo);
	ourInstance->myResolution.Init(aSetupInfo.resolution);

	if(aSetupInfo.useScissorRect)
	{
		ourInstance->myResolution.SetupScissorRect();
	}

	return true;
}

void Graphics::Engine::Destroy()
{
	delete ourInstance;
	ourInstance = NULL;
}

Graphics::Engine* Graphics::Engine::GetInstance()
{
	return ourInstance;
}

LPDIRECT3DDEVICE9 Graphics::Engine::GetDevice()
{
	return ourInstance->myDevice.GetDevice();
}

HWND Graphics::Engine::GetWindow()
{
	return ourInstance->myDevice.GetWindow();
}

Graphics::EffectContainer& Graphics::Engine::GetEffectContainer()
{
	return myEffectContainer;
}

Graphics::TextureContainer& Graphics::Engine::GetTextureContainer()
{
	return myTextureContainer;
}

Graphics::Resolution& Graphics::Engine::GetResolution()
{
	return myResolution;
}

void Graphics::Engine::Update()
{
	myRenderer.Update();
}

void Graphics::Engine::Render()
{
	myRenderer.Render();
}

Graphics::Engine::Engine()
{

}

Graphics::Engine::~Engine()
{
	myDevice.Destroy();
}

